home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3424 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Please help ?!
  5. Date: 28 Jan 1996 22:25:42 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Jan28152542@qcd.lanl.gov>
  8. References: <4dm889$3hs@neptunus.pi.net> <4drnv1$cr@news.iag.net> <4drq5i$cr@news.iag.net>
  9.     <4e6hse$dvl@ns.RezoNet.NET> <310a2389.49571776@nntp.ix.netcom.com>
  10.     <4eg6h8$1db5@info.estec.esa.nl> <TANMOY.96Jan28100725@qcd.lanl.gov>
  11.     <4egm05$1da3@info.estec.esa.nl>
  12. NNTP-Posting-Host: qcd.lanl.gov
  13. Mime-Version: 1.0
  14. Content-Type: text
  15. In-reply-to: 328pt@SPOD2.dev.esoc.esa.de's message of 28 Jan 1996 20:23:33 GMT
  16.  
  17. In article <4egm05$1da3@info.estec.esa.nl> 328pt@SPOD2.dev.esoc.esa.de
  18. (Phil Tregoning) writes: 
  19. <snip>
  20.    tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) writes:
  21.  
  22.    [Talk about casting return from malloc() when stdlib.h is not
  23.    #include'd]
  24.  
  25.    >[...] The compiler _need not_ warn about an undeclared
  26.    >function (i.e. such a warning is not mandated by ANSI: no warning is
  27.    >however ever prohibited). Converting an int to a pointer without a
  28.    >cast, however, needs a warning. On such compilers, then, avoiding the
  29.    >cast can often help spot a fatal error.
  30.  
  31.    Does converting one type of pointer to another (excluding void *)
  32.    without an appropriate cast require a warning, or is that also up
  33.    to the compliler ?  K&R2 says this is illegal. 
  34.  
  35. Pointer conversions without a cast are allowed only when converting a
  36. non-function pointer to/from a void* pointer. Every other conversion
  37. involving pointers is allowed with and need explicit casts. The
  38. validity of such conversions between non-function pointers with cast
  39. depends on alignment, and hence care must be taken if portable code is
  40. desired    . A function and a non-function pointer may not be mixed in
  41. portable code at all, though all function pointers may be cast to one
  42. another portably.
  43.  
  44. A diagnostic is never required when an explicit cast is allowed and
  45. present. 
  46.  
  47. Cheers
  48. Tanmoy
  49. --
  50. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  51. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  52. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  53. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  54. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  55. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  56.